//
//  YFAlert.m
//  project
//
//  Created by yefei on 2019/5/7.
//  Copyright © 2019 健健. All rights reserved.
//

#import "YFAlert.h"
#import "LEEAlert.h"

@implementation YFAlert

#pragma mark - 绝对单例
static YFAlert *_manager = nil;
+ (instancetype)shared {
    
    static dispatch_once_t onceToken = 0;
    dispatch_once(&onceToken, ^{
        _manager = [[self alloc] init];
    });
    return _manager;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    static dispatch_once_t onceToken = 0;
    dispatch_once(&onceToken, ^{
        _manager = [super allocWithZone:zone];
    });
    return _manager;
}

- (instancetype)copyWithZone:(NSZone *)zone {
    return _manager;
}

- (instancetype)mutableCopyWithZone:(NSZone *)zone {
    return _manager;
}


+ (YFAlert *(^)(void(^completeion)(BOOL isDelete)))showDeleteMyDongtai {
    
    return ^YFAlert *(void(^completeion)(BOOL isDelete)) {
        
        [LEEAlert actionsheet].config.LeeAddAction(^(LEEAction * _Nonnull action) {
            
            action.title = @"删除";
            action.titleColor = [UIColor withHexString:@"#FF2400"];
            action.clickBlock = ^{
                completeion(YES);
            };
        }).LeeAddAction(^(LEEAction * _Nonnull action) {
            
            action.title = @"取消";
            action.titleColor = [UIColor withHexString:@"#999999"];
            action.clickBlock = ^{
                completeion(NO);
            };
        })
        .LeeActionSheetBottomMargin(0.0f)
        .LeeCornerRadius(0.0f)
        .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type) {
            
            return CGRectGetWidth([[UIScreen mainScreen] bounds]);
        })
        .LeeActionSheetBackgroundColor([UIColor whiteColor]).LeeShow();
        
        return YFAlert.shared;
    };
}

+ (YFAlert *(^)(void(^completeion)(BOOL isDelete)))showDeleteConfirmMyDongtai {
    
    return ^YFAlert *(void(^completeion)(BOOL isDelete)) {
        
        UIImageView *tipImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sucess"]];
        
        [LEEAlert alert].config.LeeAddCustomView(^(LEECustomView * _Nonnull custom) {
            custom.view = tipImageView;
        })
        .LeeAddTitle(^(UILabel *lb) {
            lb.text = @"一旦删除，翻箱倒柜都找不回来哟～";
            lb.textColor = UIColor.blackColor;
            lb.font = [UIFont fontWithName:PingFangSC_Regular size:14];
        })
        .LeeAddAction(^(LEEAction *action) {
            
            action.type = LEEActionTypeDefault;
            action.title = @"再想想";
            action.titleColor = UIColor.blackColor;
            action.backgroundColor = [UIColor whiteColor];
            action.font = [UIFont fontWithName:PingFangSC_Regular size:16];
            action.clickBlock = ^{
                
                // 取消点击事件Block
                completeion(NO);
            };
        })
        .LeeAddAction(^(LEEAction *action) {
            
            action.type = LEEActionTypeDefault;
            action.title = @"删";
            action.titleColor = UIColor.blackColor;
            action.backgroundColor = [UIColor whiteColor];
            action.font = [UIFont fontWithName:PingFangSC_Regular size:16];
            action.clickBlock = ^{
                
                // 取消点击事件Block
                completeion(YES);
            };
        }).LeeShow();
        
        return YFAlert.shared;
    };
}

@end
